package com.pig4cloud.pig.item.controller;

import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by caoxuel on 2020/10/14 15:32
 *
 * @author caoxuel
 */
@RestController
//@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 获得一级分类
     *
     * @return
     */
    @GetMapping("/getCategoryName")
    public R getCategoryName() {
        return R.ok(categoryService.getCategoryName());
    }

    /**
     * 获得下级分类
     *
     * @return
     */
    @PutMapping("/getSecondaryClass/{categoryName}")
    public R getSecondaryClass(@PathVariable String categoryName) {
        return R.ok(categoryService.getSecondaryClass(categoryName));
    }
}
